const formatTime = date => {
    const year = date.getFullYear()
    const month = date.getMonth() + 1
    const day = date.getDate()
    const hour = date.getHours()
    const minute = date.getMinutes()
    const second = date.getSeconds()
  
    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
  }
  
  const formatNumber = n => {
    n = n.toString()
    return n[1] ? n : '0' + n
  }
  
  // var myFunction={
  //     getToken: function(){//无参数全局函数
  //         wx.qy.login({
  //             success(wxres) {
  //                 console.log("code是"+wxres.code)
  
  //               if (wxres.code) {
  //                 app.formGet('/inApi/qywx/student/auth/appletLogin', {
  //                   "code": wxres.code
  //                 }).then(res => {
  //                   if (res.code == 1) {
  //                     wx.setStorageSync('token', res.response.token)
  //                     wx.reLaunch({
  //                       url: '/pages/index/index',
  //                     });
  //                   }
  //                   else {
  //                     _this.message(res.message, '您无该系统的权限，请联系系统管理员')
      
  //                         wx.reLaunch({
  //                       url: '/pages/403/index',
  //                     });
  //                   }
  //                 }).catch(e => {
  //                   _this.message(e, 'error')
  //                 })  
  //               } else {
  //                 _this.message(res.errMsg, 'error')
  //               }
  //             }
  //           })
  //     },//多个函数使用逗号做分割
  
  //     },
    
  const formatSeconds = theTime => {
    let theTime1 = 0
    let theTime2 = 0
    if (theTime > 60) {
      theTime1 = parseInt(theTime / 60)
      theTime = parseInt(theTime % 60)
      if (theTime1 > 60) {
        theTime2 = parseInt(theTime1 / 60)
        theTime1 = parseInt(theTime1 % 60)
      }
    }
    let result = '' + parseInt(theTime) + '秒'
    if (theTime1 > 0) {
      result = '' + parseInt(theTime1) + '分' + result
    }
    if (theTime2 > 0) {
      result = '' + parseInt(theTime2) + '小时' + result
    }
    return result
  }
  
  
  module.exports = {
    formatSeconds: formatSeconds,
    formatTime: formatTime,
  //   myFunction:myFunction 
  }